Questions
36 of 50
1What is a pseudo-class in CSS?
2How are pseudo-classes different from pseudo-elements?
3What is the syntax of a pseudo-class in CSS?
4Give some commonly used pseudo-classes.
5What does the :hover pseudo-class do?
6What’s the purpose of the :active pseudo-class?
7How does the :visited pseudo-class work for links?
8What is the :focus pseudo-class used for?
9What does the :checked pseudo-class do?
10How does the :disabled pseudo-class behave?
11What is the difference between :first-child and :first-of-type?
12How do :nth-child() and :nth-of-type() differ?
13How do you select every odd or even element using pseudo-classes?
14How can you style an element when it’s being hovered over along with its child?
15What does the :not() pseudo-class do?
16How can you use multiple pseudo-classes together?
17What is the difference between :link and :visited?
18What does the :target pseudo-class represent?
19How can you use :empty to detect empty elements?
20How does the :root pseudo-class differ from the html selector?
21What does the :valid and :invalid pseudo-class do?
22How can you use :required and :optional pseudo-classes in forms?
23What is the use of :in-range and :out-of-range?
24What does :read-only and :read-write do?
25How can you style an input field when it’s autofilled?
26How does the :focus-within pseudo-class work?
27What’s the difference between :focus and :focus-visible?
28What is the purpose of the :placeholder-shown pseudo-class?
29How can you style a checkbox when it is checked or unchecked?
30How can you style invalid form inputs without JavaScript?
31Can pseudo-classes be chained together? Give an example.
32What is the specificity of pseudo-classes compared to normal selectors?
33How can you use :not() effectively to exclude elements from styling?
34How does :has() pseudo-class work, and why is it powerful?
35Is :has() supported in all browsers?
36How does :is() differ from :where() in terms of specificity?
37How can you combine :is() or :where() with other selectors for cleaner code?
38What’s the difference between :nth-child() and :nth-last-child()?
39How can you style only the last element of a list using pseudo-classes?
40What does the :lang() pseudo-class do?
41How do you change a button’s color when hovered but not when disabled?
42How can you highlight the current section in a menu using :target?
43How can you style a form field differently when focused and valid?
44How do you style every third list item differently?
45How can you style alternate table rows without adding extra classes?
46How do you hide empty <p> tags using pseudo-classes?
47How can you style the parent when any child inside it is focused?
48How can you highlight a link only when it’s both focused and hovered?
49How can you style the first letter of only the first paragraph using pseudo-classes?
50How would you use :has() to select a <div> that contains an image?
36 / 50

How does :is() differ from :where() in terms of specificity?

Understanding :is() vs :where() in CSS

The :is() and :where() pseudo-classes allow you to group multiple selectors and apply styles efficiently, but they differ in how they contribute to specificity.

Key Differences in Specificity
  1. 1

    :is(selector-list) – The specificity of :is() is equal to the most specific selector inside the list. This means it can override less specific rules.

  2. 2

    :where(selector-list) – The specificity of :where() is always zero, regardless of the selectors inside it. This makes it ideal for utility or default styles that should not override other rules.

  3. 3

    Both simplify writing complex selectors, but :where() avoids specificity conflicts while :is() preserves them.

Example: :is() vs :where() Specificity

In this example, the headings get dark blue because :is() preserves specificity. The regular paragraph gets gray from :where(), but the .special paragraph overrides it with black because :where() has zero specificity.

Best Practices
  1. 1

    Use :is() when you want grouped selectors to maintain specificity and possibly override other rules.

  2. 2

    Use :where() for default or fallback styles that should not interfere with more specific rules.

  3. 3

    Combine them with other pseudo-classes for precise and readable CSS.

  4. 4

    Test across browsers, as support for :is() and :where() is broad in modern browsers but may require fallback for older ones.

Difficulty: 6/10
Topics: specificity, selector matching, CSS specificity inheritance

Scenario Questions

0-2 years experience
  1. 1

    You have a button with a class .primary and you're trying to style it with :is(.primary, .accent) — but your styles aren't taking effect. Why might that be?

  2. 2

    If you write :where(.header, .nav) { color: blue; } and .header { color: red; }, what color will the header text be? Why?

  3. 3

    You're using :is() to group selectors for a form input, but it's being overridden by a more specific rule. How would you fix it?

2-5 years experience
  1. 1

    A designer says the theme colors aren't applying consistently across components — you notice they're using :where() for global resets but some components still override them. What’s likely happening and how would you fix it?

  2. 2

    Your team’s CSS library uses :is() for utility classes, but now some custom component styles are breaking because of specificity conflicts. How would you diagnose and resolve this?

  3. 3

    You’re debugging a layout where a :where() rule isn’t overriding a hardcoded inline style — why is that, and what’s your next step?

5-8 years experience
  1. 1

    You're designing a design system where global resets need to be non-intrusive but still allow component-level overrides. Would you use :is() or :where()? Justify your choice and describe how you'd structure the CSS architecture.

  2. 2

    In a large codebase with 50+ components, you notice inconsistent styling behavior when switching between :is() and :where(). How would you audit and standardize their usage across teams?

  3. 3

    You're optimizing a legacy UI for performance and reducing CSS bundle size. How might replacing :is() with :where() in certain contexts improve maintainability or reduce specificity conflicts?

8+ years experience
  1. 1

    You're leading a migration from a legacy CSS framework to a modern one that heavily uses :is() and :where(). How would you design a strategy to audit, document, and enforce correct usage across 10+ engineering teams without breaking existing UIs?

  2. 2

    Your company is building a multi-tenant SaaS platform where each tenant can inject custom CSS. How would you architect the core UI library to use :is() and :where() in a way that prevents tenant styles from accidentally overriding system styles — or vice versa?

  3. 3

    You're evaluating whether to standardize on :where() for all global utility classes across the organization. What are the long-term maintenance, debugging, and onboarding tradeoffs you'd present to the engineering leadership?

Follow-up Questions

  • What happens if you nest :is() inside another :is()?
  • How would you debug a style not applying because of unexpected specificity?
  • Can you use :where() to override a class-based style?